package cloud.simple.service.web;

import java.util.List;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import cloud.simple.service.model.User;
import cloud.simple.service.service.UserService;

/**
 *
 * @author 程序猿DD
 * @version 1.0.0
 * @blog http://blog.didispace.com
 *
 */
@RestController
public class UserController {

	Logger logger = Logger.getLogger(UserController .class);
	
	@Autowired
	private UserService service;
	
	protected UserService getService(){
		return service;
	}
	
	
	
	@RequestMapping(value="/user",method=RequestMethod.GET)
    public String getUsers() {
        List<User> users = getService().searchAll();
        String str = "";
        if(users.size()!=0){
        	for(User user : users){
        		str+="========"+user.getUserName();
        	}
        }
        return str;
    }

    @RequestMapping("/")
    public String index(ModelMap map) {
        map.addAttribute("host", "http://blog.didispace.com");
        return "index";
    }

}